package Operation;

import Book.Book;

import Book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner in = new Scanner(System.in);
        System.out.println("增加图书");
        System.out.println("请输入书名");
        String name = in.nextLine();
        System.out.println("请输入作者");
        String author = in.nextLine();
        System.out.println("请输入价格");
        double price = in.nextDouble();
        System.out.println("请输入书的类型");
        String type = in.nextLine();
        Book book = new Book(name,author,price,type);
        int pos = bookList.getBookSize();
        bookList.putBook(pos,book);
        bookList.setBookSize(pos+1);
        System.out.println("添加成功");
    }
}
